from fastapi import Depends, APIRouter, Request
from sqlalchemy.ext.asyncio import AsyncSession

from config import get_db
from module_admin.aspect.interface_auth import CheckUserInterfaceAuth
from module_admin.entity.vo.business.sms_record_vo import SmsRecordPageQueryModel
from module_admin.service.business.sms_record_service import SmsRecordService
from module_admin.service.login_service import LoginService
from utils.page_util import PageResponseModel
from utils.response_util import ResponseUtil

smsRecordController = APIRouter(prefix='/sms_record', dependencies=[Depends(LoginService.get_current_user)])


@smsRecordController.get('/list', response_model=PageResponseModel,
                         dependencies=[Depends(CheckUserInterfaceAuth('business:sms_record:list'))])
async def get_sms_record_list(
        request: Request,
        sms_record_page_query: SmsRecordPageQueryModel = Depends(SmsRecordPageQueryModel.as_query),
        query_db: AsyncSession = Depends(get_db)
):
    """
    获取短信记录信息列表
    """
    sms_record_query_result = await SmsRecordService.get_sms_record_list_services(query_db, sms_record_page_query,
                                                                                  is_page=True)
    return ResponseUtil.success(model_content=sms_record_query_result)
